Skip to content

fix(id): validate journal headers in replication payloads (#4486) - #4550

Merged
dezren39 merged 1 commit into
mainfrom
queue/6439-4486-journal-header-validation
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/6439-4486-journal-header-validation

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #4486 (task 6439).

ReplicationTracker::accept verified that each payload line decodes as a journal entry, but never checked the payload's own journal header — a signed Snapshot with no header, a foreign world's header, a mismatched header version, or a duplicate header advanced the verified cursor over a journal WorldCore::restore refuses.

Change (pkgs/id/src/world/replication.rs only)

  • New ReplicationError::InvalidJournalHeader.
  • validate_payload_journal_header, called from accept in the Snapshot and Tail arms before any state changes:
    • Snapshot: first entry must be exactly one Created header whose world_id and version equal the envelope's world_id and header_version; any later Created is refused; an empty snapshot is a missing header.
    • Tail: a tail starting at the chain base carries journal entry 0 itself, so its first entry may be that same matching header; any other Created in a tail is a second header mid-journal and is refused.
    • Every refusal leaves tracker state unchanged (validation runs before the chain/cursor mutation).
  • Regression test snapshot_and_tail_payloads_must_carry_the_journals_own_header covers all five packet cases — missing header, foreign-world header, payload version mismatch, duplicate header, Created in Tail — asserting the cursor does not move on refusal.
  • The header-bump rebase test now carries a version-2 header in its version-2 snapshot payload (previously it reused the version-1 fixture, which the new contract correctly refuses).

Out of scope per the packet: envelope header_version lower bound (#4471), references.rs (#4454/#4455), network/durable replica work.

Tests

  • Laptop, from pkgs/id: cargo test --lib world::replication — 11 passed, 0 failed (includes existing round-trip, rebase, gap/fork/replay, and tamper tests).

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 19:37
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 98e32c10-e789-4dc7-9e3d-f3851a077594
Commits

Reviewing files that changed from the base of the PR and between b401d03 and 16b434e.

Files selected for processing: 1
  • pkgs/id/src/world/replication.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T19:38:51.091874Z 16b434e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant